package com.thekernel.youdaoyun.service;

import com.thekernel.youdaoyun.YoudaoyunApplication;
import com.thekernel.youdaoyun.bean.Star;
import com.thekernel.youdaoyun.exception.MyException;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * @Author TheKernel
 * @Date 2019/9/14 1:30 下午
 * @Version 1.0
 * @Description 测试 StarService
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = YoudaoyunApplication.class)
public class testStarService {

    @Autowired
    private StarService starService;

    @Test
    public void testAddExistsStar() {
        Star star = new Star();
        star.setStarNote(1);
        star.setStarUser(1);

        Assert.assertEquals(0, this.starService.addStar(star));
    }

    @Test
    public void testCancelStar() throws MyException {
        long starId = 1;  // 测试收藏 id
        long userId = 1;  // 测试用户 id

        Assert.assertEquals(1, this.starService.cancelStar(starId, userId));
    }

}
